package flexo.gui.flat;

import flexo.math.Coords;
import flexo.scene.Node;

public class Panel extends flexo.gui.Panel 
{
	flexo.graphic.entity.Quad quad;
	
	public Panel(String name, Coords size, String panelMat) 
	{
		super(name, size);
		flexo.graphic.GraphicSystem gs = (flexo.graphic.GraphicSystem)flexo.Kernel.getSystem(flexo.graphic.GraphicSystem.ID);
		quad = gs.addQuad(this.size.x, this.size.y);
		quad.setMaterial(panelMat);
	}
	
	void setMaterial(String material)
	{
		quad.setMaterial(material);
	}
	
	@Override
	public boolean attachTo(Node n)
	{
		boolean result = super.attachTo(n);
		if (result)
		{
			quad.attachTo(n);
		}
		return result;
	}
	
	public void deattachFrom(Node n)
	{
		quad.deattachFrom(n);
		super.deattachFrom(n);
	}
}
